<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gym Rat | Programs</title>
<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
	</script>
<script type="text/javascript">

</script>
</head>

<body>
<jsp:include page="/includes/nav.jsp" />
<c:if test="${result != null}">
${result}<br>
</c:if>
<h1>Active Programs</h1>
<ul>
	<li><a href="<c:url value='/program/create.jsp' />">Create a
	Program</a></li>
</ul>
<table width="100%">
	<c:forEach var="program" items="${programs}" varStatus="status">
		<tr class="tableHeader">
			<td colspan=3>${program.name}</td>
			<td><a class="headerLink"
				href="<c:url value='/program/modify?id=${program.id }' />">edit</a></td>
		</tr>
		<tr class="tableHeader">
			<td>Routine Name</td>
			<td>Day</td>
			<td>Last Workout</td>
			<td>Options</td>
		</tr>
		<c:if test="${fn:length(program.routines) == 0}">
			<tr>
				<td colspan=4>There are currently no routines in this program</td>
			</tr>
		</c:if>
		<c:forEach var="routine" items="${program.routines}"
			varStatus="status">
			<c:choose>
				<c:when test="${status.count % 2 == 1 }">
					<c:set var="rowClass" value="tableOddRow" />
				</c:when>
				<c:otherwise>
					<c:set var="rowClass" value="tableEvenRow" />
				</c:otherwise>
			</c:choose>
			<tr class="${rowClass }">
				<td><a
					href="<c:url value='/log/add?routineid=${routine.id}' />">${routine.name}</a>
				</td>
				<td>${routine.programNote }</td>
				<td><a
					href="<c:url value='/log/view/filter?filter=byRoutine&routineSelect=${routine.id }' />">${routine.logs[0].dateWorked
				}</a></td>
				<td><a
					href="<c:url value='/routine/modify?id=${routine.id}' />">edit</a>
				<form id="voteup${routine.id}" action="vote" method="post"><input
					type="hidden" name="id" value="${routine.sourceId }"> <input
					type="hidden" name="vote" value="1"></form>
				<form id="votedown${routine.id}" action="vote" method="post"><input
					type="hidden" name="id" value="${routine.sourceId }"> <input
					type="hidden" name="vote" value="-1"></form>
				</td>
			</tr>

		</c:forEach>
	</c:forEach>
</table>
</body>
</html>